/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fr.ensma.ia.miniblog.sbeans;

import fr.ensma.ia.miniblog.persistence.Article;
import fr.ensma.ia.miniblog.persistence.Commentaire;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author LeBlero
 */
@Stateless
public class CommentaireBean implements ICommentaireLocal {

    @PersistenceContext(unitName="MiniBlog_PUnit")
    private EntityManager em;

    @Override
    public Commentaire createCommentaire(Commentaire c) {
        em.persist(c);
        return c;
    }

    @Override
    public Commentaire getCommentaireById(Long id) {
        return em.find(Commentaire.class, id);
    }

    @Override
    public void deleteCommentaire(Commentaire c) {
        Commentaire com = em.merge(c);
        em.remove(com);
    }

    @Override
    public List<Commentaire> getCommentairesByArticle(Article a) {
        //TODO
        return null;
    }
    

}
